<!--
 * @Author: windy
 * @Date: 2021-07-16 10:57:48
 * @LastEditTime: 2021-07-16 11:31:24
 * @LastEditors: windy
 * @Description: 
-->
<template>
  <div>
    <a-button type="primary" @click="go">起风了</a-button>
    <p>vuex</p>
    <div>
      {{ count }}
      <a-button type="primary" @click="addCount">Add</a-button>
    </div>
    <div>
      <a-button type="primary" @click="getVersion">点击获取版本(mock)</a-button>
      name: {{ name }}, version: {{ version }}
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  data() {
    return {
      name: "",
      version: "",
    };
  },
  computed: {
    ...mapState(["count"]),
  },
  methods: {
    go() {
      this.$router.push({ path: "/windy" });
    },
    addCount() {
      this.$store.commit("setData", { key: "count", value: this.count + 1 });
    },
    getVersion() {
      this.$axios.get("/getVersion").then(({ data }) => {
        console.log("🚀 ~ this.$axios.get ~ res", data);
        this.version = data.data.version;
        this.name = data.data.name;
      });
    },
  },
};
</script>

<style lang="less" scoped></style>
